<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="device" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{deviceHome.managed ? 'Edit' : 'Add'} Device</f:facet>



            <s:decorate id="nameField" template="layout/edit.xhtml">
                <ui:define name="label">Name</ui:define>
                <h:inputText id="name"
                       required="true"
                           size="100"
                      maxlength="100"
                          value="#{deviceHome.instance.name}">
                    <a:support event="onblur" reRender="nameField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="typeField" template="layout/edit.xhtml">
                <ui:define name="label">Type</ui:define>
                <h:inputText id="type"
                       required="true"
                           size="6"
                      maxlength="6"
                          value="#{deviceHome.instance.type}">
                    <a:support event="onblur" reRender="typeField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>



            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{deviceHome.persist}"
                       disabled="#{!deviceHome.wired}"
                       rendered="#{!deviceHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{deviceHome.update}"
                       rendered="#{deviceHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{deviceHome.remove}"
                      immediate="true"
                       rendered="#{deviceHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/Device.xhtml"
                rendered="#{deviceHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty deviceFrom ? 'DeviceList' : deviceFrom}.xhtml"
                rendered="#{!deviceHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Device actionses">
        <h:form styleClass="association" id="deviceActionsesChildren">

            <h:outputText value="There are no deviceActionses associated with this device."
                       rendered="#{empty deviceHome.deviceActionses}"/>

            <rich:dataTable value="#{deviceHome.deviceActionses}"
                           var="_deviceActions"
                      rendered="#{not empty deviceHome.deviceActionses}"
                    rowClasses="rvgRowOne,rvgRowTwo"
                            id="deviceActionsesTable">
                <rich:column sortBy="#{_deviceActions.deviceActionsId}">
                    <f:facet name="header">Device actions id</f:facet>
                    <h:outputText value="#{_deviceActions.deviceActionsId}"/>
                </rich:column>
                <rich:column sortBy="#{_deviceActions.actionType}">
                    <f:facet name="header">Action type</f:facet>
                    <h:outputText value="#{_deviceActions.actionType}"/>
                </rich:column>
                <rich:column sortBy="#{_deviceActions.name}">
                    <f:facet name="header">Name</f:facet>
                    <h:outputText value="#{_deviceActions.name}"/>
                </rich:column>
            </rich:dataTable>

        </h:form>

        <f:subview rendered="#{deviceHome.managed}" id="deviceActionses">
        <div class="actionButtons">
            <s:button id="adddeviceActions"
                   value="Add deviceActions"
                    view="/DeviceActionsEdit.xhtml"
             propagation="none">
                 <f:param name="deviceDeviceId"
                         value="#{deviceHome.instance.deviceId}"/>
                 <f:param name="deviceActionsFrom" value="Device"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>

    <rich:tab label="Status actionses">
        <h:form styleClass="association" id="statusActionsesChildren">

            <h:outputText value="There are no statusActionses associated with this device."
                       rendered="#{empty deviceHome.statusActionses}"/>

            <rich:dataTable value="#{deviceHome.statusActionses}"
                           var="_statusActions"
                      rendered="#{not empty deviceHome.statusActionses}"
                    rowClasses="rvgRowOne,rvgRowTwo"
                            id="statusActionsesTable">
                <rich:column sortBy="#{_statusActions.statusActionId}">
                    <f:facet name="header">Status action id</f:facet>
                    <h:outputText value="#{_statusActions.statusActionId}"/>
                </rich:column>
                <rich:column sortBy="#{_statusActions.statusAction}">
                    <f:facet name="header">Status action</f:facet>
                    <h:outputText value="#{_statusActions.statusAction}"/>
                </rich:column>
            </rich:dataTable>

        </h:form>

        <f:subview rendered="#{deviceHome.managed}" id="statusActionses">
        <div class="actionButtons">
            <s:button id="addstatusActions"
                   value="Add statusActions"
                    view="/StatusActionsEdit.xhtml"
             propagation="none">
                 <f:param name="deviceDeviceId"
                         value="#{deviceHome.instance.deviceId}"/>
                 <f:param name="statusActionsFrom" value="Device"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
